#ifndef KONTRAST_H
#define KONTRAST_H

#include <QObject>
#include <QQmlEngine>
#include <QColor>
#include <QPixmap>

class QScreen;
class QSettings;

class Kontrast : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
    Q_PROPERTY(QColor bkcolor READ bkcolor WRITE setBkcolor NOTIFY bkcolorChanged FINAL)
    Q_PROPERTY(bool is_bk READ is_bk WRITE setIs_bk NOTIFY is_bkChanged FINAL)
    Q_PROPERTY(QList<QString> color_pairs READ color_pairs NOTIFY color_pairsChanged FINAL)
    QML_ELEMENT
    QML_SINGLETON
public:
    explicit Kontrast(QObject *parent = nullptr);

    Q_INVOKABLE void pick(bool is_bk = false);

    Q_INVOKABLE void mark_favorite();

    Q_INVOKABLE void remove_favorite(int index);

    Q_INVOKABLE void copy(QString const color);

    bool eventFilter(QObject *watched, QEvent *event) override;

    QColor color() {return _color;}
    void setColor(QColor color){_color = color; emit colorChanged();}

    QColor bkcolor() {return _bkcolor;}
    void setBkcolor(QColor color){_bkcolor = color; emit bkcolorChanged();}

    bool is_bk() {return _is_bk;}
    void setIs_bk(bool is_bk){_is_bk = is_bk; emit is_bkChanged();}

    QList<QString> color_pairs() {return _color_pairs;}

signals:
    void colorChanged();
    void bkcolorChanged();
    void is_bkChanged();
    void color_pairsChanged();

private:
    QScreen *pscreen;
    QPixmap pixmap;

    QColor _color;
    QColor _bkcolor;
    bool _is_bk;

    QList<QString> _color_pairs;

    QSettings *psettings;
};

#endif // KONTRAST_H
